function filter(arr, filterCallback) {
    if(!Array.isArray(arr) || !arr.length || typeof filterCallback !== 'function'){
        return [];
    }else {
        let result = [];
        for(let i = 0; i < arr.length; i++){
            if(filterCallback(arr[i],i,arr)) {
                result.push(arr[i]);
            }
        }
        return result;
    }
}   

const arr = [1,2,3,4,5,6];
console.log(filter(arr, (item) => item % 2 === 0));
